#include <iostream>
#include <list>

using std::cout;
using std::endl;
using std::list;

template <typename Container>
void display(const Container &con)
{
    for(auto &elem : con)
    {
        cout << elem << "  ";
    }
    cout << endl;
}

void test()
{
    list<int> number = {1, 3, 8, 5, 7, 9, 10, 40, 20};
    display(number);

    cout << endl << endl;
    auto it = number.begin();
    cout << "*it = " << *it << endl;
    auto it2 = number.begin();
    ++it2;
    ++it2;
    cout << "*it2 = " << *it2 << endl;
    auto it3 = number.end();
    --it3;
    --it3;
    cout << "*it3 = " << *it3 << endl;
    number.splice(it, number, it2, it3);
    display(number);
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

